# rewrite to use files in patches directory


import os
import sys
import shutil

PATCHES_DIR = os.path.join('..', 'requirements')

if sys.platform == 'win32':
    SITE_PACKAGES = os.path.join(r'..\virtualenv\Lib\site-packages')
else:
    py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
    SITE_PACKAGES = os.path.join('../virtualenv/lib/' + py_version + '/site-packages')


SOURCE_FILES = (
#    os.path.join('patch', 'bookmarks', 'forms.py'),
#    os.path.join('patch', 'docutils', 'roman.py'),
#    os.path.join('patch', 'django_mysql', 'base.py'),
#    os.path.join('patch', 'django_postgres', 'base.py'),
#    os.path.join('patch', 'pinax_templates', 'join_invite_message.txt'),
#    os.path.join('patch', 'pinax_templates', 'join_invite_subject.txt'),
#    os.path.join('patch', 'pinax_templates', 'password_reset_key_message.txt'),
#    os.path.join('patch', 'pinax_templates', 'password_reset_message.txt'),
#    os.path.join('patch', 'pinax', 'apps', 'authsub', 'views.py'),
#    os.path.join('patch', 'django_friends-0.1.0-py2.5.egg', 'friends', 'importer.py'),
#    os.path.join('patch', 'django_microblogging-0.1.0-py2.5.egg', 'microblogging', 'forms.py'),
#    os.path.join('patch', 'django_microblogging-0.1.0-py2.5.egg', 'microblogging', 'models.py'),
)

DESTINATION_FILES = (
#    os.path.join(SITE_PACKAGES, 'bookmarks', 'forms.py'),
#    os.path.join(SITE_PACKAGES, 'docutils', 'parsers','rst', 'roman.py'),
#    os.path.join(SITE_PACKAGES, 'django', 'db', 'backends', 'mysql', 'base.py'),
#    os.path.join(SITE_PACKAGES, 'django', 'db', 'backends', 'postgresql_psycopg2', 'base.py'),
#    os.path.join(SITE_PACKAGES, 'Pinax-0.7beta2-py2.5.egg', 'pinax', 'templates', 'default', 'friends', 'join_invite_message.txt'),
#    os.path.join(SITE_PACKAGES, 'Pinax-0.7beta2-py2.5.egg', 'pinax', 'templates', 'default', 'friends', 'join_invite_subject.txt'),
#    os.path.join(SITE_PACKAGES, 'Pinax-0.7beta2-py2.5.egg', 'pinax', 'templates', 'default', 'account', 'password_reset_key_message.txt'),
#    os.path.join(SITE_PACKAGES, 'Pinax-0.7beta2-py2.5.egg', 'pinax', 'templates', 'default', 'account', 'password_reset_message.txt'),
#    os.path.join(SITE_PACKAGES, 'Pinax-0.7beta2-py2.5.egg', 'pinax', 'apps', 'authsub', 'views.py'),
#    os.path.join(SITE_PACKAGES, 'django_friends-0.1.0-py2.5.egg', 'friends', 'importer.py'),
#    os.path.join(SITE_PACKAGES, 'django_microblogging-0.1.0-py2.5.egg', 'microblogging', 'forms.py'),
#    os.path.join(SITE_PACKAGES, 'django_microblogging-0.1.0-py2.5.egg', 'microblogging', 'models.py'),
)

def patch_requirements():
    for index, destination in enumerate(DESTINATION_FILES):
        shutil.copyfile(SOURCE_FILES[index], destination)
        print('Patched ' + destination)
        
if __name__ == '__main__':
    patch_requirements()
    
